package visualcbir.format;

import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.sf.epsgraphics.ColorMode;
import net.sf.epsgraphics.EpsGraphics;


public class FormatEps implements IFormat {

     @Override
    public void printFormat(File file, IPrintable printable) {
        try {
            FileOutputStream outputStream = null;
            outputStream = new FileOutputStream(file);
            EpsGraphics g = new EpsGraphics("EpsOutput", outputStream, 0, 0, 500, 500, ColorMode.COLOR_RGB);
            System.out.println("antes de paint");
            //jComponent.setDoubleBuffered(false);
            //RepaintManager.currentManager(jComponent).setDoubleBufferingEnabled(false);
            //jComponent.paint(g);// funcionaria as vezes. se se chama paintComponents em jComponents, nada sera impreso.
            //jComponent.paintComponent(g);// nao se ve este metodo porque é protected e aqui somente se tem acesso aos métodos public
            //jComponent.printComponents(g);//funciona como paint
            
            printable.printWithGraphics(g);
            System.out.println("acabo paint");
            System.out.println(g.toString());
            //g.flush();// Flush and close the document (don't forget to do this!)
            //g.close();
            outputStream.close();
        } catch (FileNotFoundException ex) {
            System.err.println("File not Found");
            Logger.getLogger(FormatEps.class.getName()).log(Level.SEVERE, null, ex);
        } catch(IOException ex){
            System.err.println("Erro de entrada/saida");
            Logger.getLogger(FormatEps.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
    

 
   

}